import { onUnmounted } from "vue";
export function useInterval(fn: () => void, delay: number) {
    const timer = setInterval(() => {
        fn()
    }, delay)
    const clear = () => {
        clearInterval(timer)
    }
    // 当组件销毁的时候清除定时器
    onUnmounted(clear)
    return clear
}